import java.util.Scanner;

public class StringSearch {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("输入一个字符串：");
        String string = input.next();
        System.out.println("输入要查找的字符：");
        String search = input.next();
        int count = 0;
        if(string.contains(search)){
            for (int i = 0; i <= string.lastIndexOf(search); i++) {
                if (search.equals(string.substring(i, i + search.length()))) {
                    i = i + search.length() - 1;
                    count++;
                }
            }
            System.out.println(search + "共出现" + count + "次");
        }else{
            System.out.println("输入有误");
        }

    }
}

